package com.zsrt.oa.integral.controller;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.zsrt.oa.integral.service.IntegralService;
import com.zsrt.oa.integral.service.impl.IntegralServiceImpl;
import com.zsrt.utils.DBUtils;

/**
 * 积分的控制层
 * @author 罗智壕-13424431416
 *
 * 2017年6月12日
 */
public class IntegralController extends HttpServlet {
	private static final long serialVersionUID = 1L;
    
	/**
	 * 初始化积分的服务层
	 */
	private IntegralService service = new IntegralServiceImpl();
	
	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response) 
			throws ServletException, IOException {
		
		String method = request.getParameter("method");
		
		if(null != method && !"".equals(method.trim())){
			Map<String, Object> map = new HashMap<String, Object>();
			HttpSession session = request.getSession();
			Object userPhone = session.getAttribute("currentUser");
			if("integralQuery".equals(method)){
				
				//调用订单的查询
				service.integralQuery((String) userPhone, map);
			}
			
			DBUtils.toJson(map, response);
		}
		
	}
}
